import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React, { useState, useEffect, useRef, useCallback } from "react";
import { MinusOutlined, PlusOutlined, CheckCircleOutlined,
// CheckOutlined,
 } from "@ant-design/icons";
import { Input, Checkbox, Card, Select, Table, Modal, Tabs, message, Popover, Tooltip, Spin, } from "antd";
import { getDataId, getPtYears, getPdYears, CHECK_BATCH_CROSS_PT_TYPE, CHECK_BATCH_CROSS_PD_TYPE, getCrossPt, getCrossPd, transformCrossData, } from "../../../../tools/Tools";
import classNames from "classnames";
import { Button } from "devextreme-react/button";
import { TableBase, TableReport, TableBook, TableFS, TrialTableFS, } from "./TableList";
import { removeVerifyData, getDisclosureData, parseVerifyFormat, } from "../../api/DesignTableApi";
import { data as testData, operations, checkType } from "./data";
import { formatValidtorData } from "./tools";
import { getHbTypeByZcbfid, MergeType } from "../../../../tools/Tools";
import { debouncedApi, removeLeadingEquals } from "./tools";
// import _ from 'lodash';
import "./_style.less";
const { TextArea } = Input;
const CheckModalComponent = (props) => {
    const { isOpen, handleOpen, params } = props;
    const [isCheckFocus, setIsCheckFocus] = useState(null);
    const tableBook = useRef(null);
    const [columnsData, setColumnsData] = useState([]);
    const [isDataFocus, setIsDataFocus] = useState(null);
    const [tabsShowValue, setTabsShowValue] = useState("1");
    const [dataList, setDataList] = useState([
        {
            number: 1,
            type: "1",
            isForce: true,
            beVerifiedFormula: "",
            operation: "==",
            verifyFormula: "",
            dynamicCondition: null,
            dateAndTimeType: "",
            dynamicMaps: "",
            beVerifyFormat: "",
            verifyFormat: "",
        },
    ]);
    const [dynamicParentFormularData, setDynamicParentFormularData] = useState([]); //设置母公式
    // const [dynamicChildFormularData, setDynamicChildFormularData] = useState([]); //设置子公式
    const [dynamicOtherChildFormularData, setDynamicOtherChildFormularData] = useState([]); //设置子公式
    const [isDynamicParent, setIsDynamicParent] = useState(false); //是否过滤掉母公式(执行重算后需要过滤掉母公式）
    useEffect(() => {
        // const formulaList =
        //   params.gridRef.articulationVerifyService.artVerifyFormulaList;
        const formulaList = params.gridRef.articulationVerifyService.artParseResultList;
        let parentFormula = []; //存储母公式
        let allFormulaList = []; //存储除了母公式以外的公式
        if (formulaList.length > 0) {
            formulaList.map((item) => {
                const { beVerifiedFormula, verifyFormula, beVerifyFormat, verifyFormat, } = item;
                const beFormulaVal = beVerifiedFormula && beVerifiedFormula.startsWith("=")
                    ? removeLeadingEquals(beVerifiedFormula)
                    : beVerifiedFormula;
                const formulaVal = verifyFormula && verifyFormula.startsWith("=")
                    ? removeLeadingEquals(verifyFormula)
                    : verifyFormula;
                const beFormatVal = beVerifyFormat && beVerifyFormat.startsWith("=")
                    ? removeLeadingEquals(beVerifyFormat)
                    : beVerifyFormat;
                const formatVal = verifyFormat && verifyFormat.startsWith("=")
                    ? removeLeadingEquals(verifyFormat)
                    : verifyFormat;
                if (item.dynamicType === "MAIN" &&
                    item?.dynamicMaps &&
                    item?.dynamicMaps !== "null") {
                    parentFormula.push({
                        ...item,
                        beVerifiedFormula: beFormulaVal,
                        verifyFormula: formulaVal,
                        beVerifyFormat: beFormatVal,
                        verifyFormat: formatVal,
                    });
                }
                else {
                    allFormulaList.push({
                        ...item,
                        beVerifiedFormula: beFormulaVal,
                        verifyFormula: formulaVal,
                        beVerifyFormat: beFormatVal,
                        verifyFormat: formatVal,
                    });
                }
            });
            allFormulaList.map((item, index) => {
                // item.number = index + 1;
                if (item && !item.number) {
                    item.number = index + 1;
                }
            });
            parentFormula.map((item, index) => {
                if (item && !item.number) {
                    item.number = index + 1;
                }
            });
            const newParentFormulaList = formatValidtorData(parentFormula);
            setDynamicParentFormularData(newParentFormulaList);
            if (newParentFormulaList && newParentFormulaList.length) {
                setIsDynamicParent(true);
            }
            //
            console.log(allFormulaList, "allFormulaList----");
            const newFormulaList = formatValidtorData(allFormulaList);
            // const newFormulaList = allFormulaList.sort(
            //   createComprisonFunction("number")
            // );
            if (newFormulaList && newFormulaList.length) {
                setDataList([...newFormulaList]);
                updateSelectColumnsRype(newFormulaList);
            }
        }
        else {
            setDataList([
                {
                    number: 1,
                    type: "1",
                    isForce: true,
                    beVerifiedFormula: "",
                    operation: "==",
                    verifyFormula: "",
                    dynamicCondition: null,
                    dateAndTimeType: "",
                    dynamicMaps: "",
                    beVerifyFormat: "",
                    verifyFormat: "",
                },
            ]);
        }
    }, [isOpen]);
    useEffect(() => {
        // yearData();
        fetchColumnData();
        fetchCheckBaseData();
        fetchReportYears();
    }, []);
    const valueRef = useRef(null);
    const [focusList, setFocusList] = useState({});
    const [selectType, setSelectType] = useState([]);
    const [selectColumnsType, setSelectColumnsType] = useState({}); //存储每一列的下拉框数据
    const [isSourceOrCheck, setIsSourceOrCheck] = useState("");
    const [isDisabled, setDisabled] = useState(false);
    const [loading, setLoading] = useState(false);
    const [confirmBtn, setConfirmBtn] = useState(false);
    const [batchOptions, setBatchOptions] = useState([]);
    const [selectBatchType, setSelectBatchType] = useState({}); //存储每一列的下拉框数据
    const [tabItems, setTabItems] = useState([]);
    const [showTabKeys, setShowTabKeys] = useState(["1"]);
    const mergeType = getHbTypeByZcbfid();
    const isMask = !(mergeType === MergeType.UNKNOW || mergeType === MergeType.TEMPLATE); //合并系统非模版编辑模式,需要展示蒙版，不能编辑校验公式
    // const [batchValue, setBatchValue] = useState({});
    const buttonDisabled = isMask ? true : false;
    useEffect(() => {
        let defaultTabItem = [
            {
                key: "1",
                label: `表内`,
                forceRender: true,
                children: (_jsx("div", { children: _jsx(TableBase, { ref: tableBook, dataList: dataList, setDataList: setDataList, sourceOrCheck: isSourceOrCheck, data: focusList, keys: tabsShowValue, gridDatas: params.gridRef.getCpasTableGrid(), parentType: params?.gridRef?.props.type, parentName: params?.gridRef?.props.name, parentParamsRef: params }) })),
                disabled: false,
            },
            mergeType === MergeType.TEMPLATE
                ? null
                : {
                    key: "2",
                    label: `报表基础数据`,
                    forceRender: true,
                    children: (_jsx("div", { children: _jsx(TableReport, { ref: tableBook, dataList: dataList, setDataList: setDataList, testColumns: columnsData, testData: testData, data: focusList, keys: tabsShowValue, sourceOrCheck: isSourceOrCheck, parentParamsRef: params }) })),
                    disabled: true,
                },
            {
                key: "3",
                label: `附注数据`,
                forceRender: true,
                children: (_jsx("div", { children: _jsx(TableBook, { ref: tableBook, keys: tabsShowValue, dataList: dataList, focusItem: focusList, setDataList: setDataList, sourceOrCheck: isSourceOrCheck, dataIndex: isCheckFocus, gridDatas: params.gridRef, parentParamsRef: params, parentType: params?.gridRef?.props.type }) })),
                disabled: true,
            },
            {
                key: "4",
                label: `报表`,
                forceRender: true,
                children: (_jsx("div", { children: _jsx(TableFS, { ref: tableBook, keys: tabsShowValue, dataList: dataList, focusItem: focusList, setDataList: setDataList, sourceOrCheck: isSourceOrCheck, dataIndex: isCheckFocus, gridDatas: params.gridRef, parentParamsRef: params, parentType: params?.gridRef?.props.type }) })),
                disabled: true,
            },
            {
                key: "5",
                label: `试算平衡表`,
                forceRender: true,
                children: (_jsx("div", { children: _jsx(TrialTableFS, { ref: tableBook, keys: tabsShowValue, dataList: dataList, focusItem: focusList, setDataList: setDataList, sourceOrCheck: isSourceOrCheck, dataIndex: isCheckFocus, gridDatas: params.gridRef, parentParamsRef: params, parentType: params?.gridRef?.props.type }) })),
                disabled: true,
            },
        ];
        showTabKeys.forEach((key, index) => {
            defaultTabItem.forEach((item, index) => {
                if (item?.key === key) {
                    item["disabled"] = false;
                }
            });
        });
        console.log(defaultTabItem, "defaultTabItem----");
        setTabItems(defaultTabItem);
    }, [
        isSourceOrCheck,
        dataList,
        focusList,
        isCheckFocus,
        tabsShowValue,
        showTabKeys,
    ]);
    useEffect(() => {
        const cpasTableRef = tableBook?.current?.cpasTableRef;
        if (cpasTableRef?.current?.hot) {
            setTimeout(() => {
                cpasTableRef?.current?.hot.render();
            }, 1500);
        }
    }, [tabItems]);
    const onCheckChange = (value, index, record) => {
        console.log(value, "value----index", index);
        updateDataList(index, value, record.dateAndTimeType);
        // if(!value.length) {
        //   setSelectBatchType({
        //     ...selectBatchType,
        //     [index]: batchOptions,
        //   });
        // }
    };
    /**
     * 更新本表需校验内容和数据源数据
     * @param index
     */
    const updateDataList = (index, value, dateAndTimeType) => {
        let newDataList = [];
        for (let i = 0; i < dataList.length; i++) {
            const item = dataList[i];
            if (i === index) {
                newDataList.push({
                    ...item,
                    beVerifiedFormula: "",
                    verifyFormula: "",
                    dateAndTimeType: dateAndTimeType || "pt",
                    dynamicCondition: value,
                    beVerifyFormat: "",
                    verifyFormat: "",
                });
            }
            else {
                newDataList.push({ ...item });
            }
        }
        setDataList(newDataList);
    };
    const fetchReportYears = async () => {
        const options = await getPtYears();
        setBatchOptions(options);
    };
    const onCheckAllChange = async (e, record, index) => {
        let allValue = [];
        const currentOptions = selectBatchType[index];
        if (currentOptions && currentOptions.length) {
            for (let i = 0; i < currentOptions.length; i++) {
                allValue.push(currentOptions[i].label);
            }
        }
        else {
            for (let i = 0; i < batchOptions.length; i++) {
                allValue.push(batchOptions[i].label);
            }
        }
        dataList.map((item, i) => {
            if (index === i) {
                item.beVerifiedFormula = "";
                item.verifyFormula = "";
                item.beVerifyFormat = "";
                item.verifyFormat = "";
                if (e.target.checked) {
                    item.dynamicCondition = allValue;
                    item.dateAndTimeType = record.dateAndTimeType || "pt";
                }
                else {
                    item.dynamicCondition = "";
                    item.dateAndTimeType = record.dateAndTimeType
                        ? record.dateAndTimeType
                        : "";
                }
            }
        });
        console.log(dataList, "dataList----");
        setDataList([...dataList]);
    };
    const batchContent = (record, index) => {
        if (buttonDisabled) {
            return;
        }
        let checklist = [];
        if (record?.dynamicCondition) {
            if (Array.isArray(record.dynamicCondition)) {
                checklist = record.dynamicCondition;
            }
            else if (typeof record.dynamicCondition === "string") {
                checklist = record.dynamicCondition.split(",");
            }
        }
        let checkAll = checklist ? batchOptions.length === checklist.length : false;
        if (selectBatchType[index]) {
            checkAll = selectBatchType[index].length === checklist.length;
        }
        let indeterminate = checklist
            ? checklist.length > 0 && checklist.length < batchOptions.length
            : false;
        if (selectBatchType[index] && checklist && checklist.length > 0) {
            indeterminate =
                checklist.length > 0 &&
                    checklist.length < selectBatchType[index].length;
        }
        return (_jsxs("div", { className: "batch-content", children: [_jsx(Checkbox, { indeterminate: indeterminate, onChange: (e) => onCheckAllChange(e, record, index), checked: checkAll, children: "\u5168\u9009" }), _jsx(Checkbox.Group, { options: selectBatchType[index] ? selectBatchType[index] : batchOptions, value: record.dynamicCondition, onChange: (e) => onCheckChange(e, index, record) }, record.dynamicCondition)] }));
    };
    //交叉校验批量点击
    const batchHandle = (index, record) => {
        console.log(selectColumnsType, index, "selectColumnsType---record", record);
        if (buttonDisabled) {
            return;
        }
        // if (batchValue[index]) {
        record.dateAndTimeType = "pt";
        if (record.dynamicCondition) {
            fetchColumnData(index);
        }
        else {
            setSelectColumnsType({
                ...selectColumnsType,
                [index]: CHECK_BATCH_CROSS_PT_TYPE,
            });
        }
        const val = !record.dynamicCondition;
        // batchValue[index] = val;
        record.dynamicCondition = val;
        record.beVerifiedFormula = "";
        record.verifyFormula = "";
        record.beVerifyFormat = "";
        record.verifyFormat = "";
        console.log(record, "record---");
        // setBatchValue({ ...batchValue });
        // updateDateTimeDataList(index);
        setDataList([...dataList]);
    };
    const renderBatch = (record, index) => {
        if (record.type === "4") {
            return (_jsx("div", { className: record.dynamicCondition
                    ? "batch-button batch-button-active"
                    : "batch-button", onClick: () => batchHandle(index, record), children: "\u6279" }));
        }
        return (_jsx(Popover, { content: record.type === "4" ? "" : batchContent(record, index), trigger: "click", placement: "bottom", children: _jsx("div", { className: record.dynamicCondition && record.dynamicCondition.length
                    ? "batch-button batch-button-active"
                    : "batch-button", children: "\u6279" }) }));
    };
    //更新datalist中的期间类型
    const updateDateTimeDataList = (index) => {
        dataList.map((item, i) => {
            if (i === index) {
                if (item.dateAndTimeType === "pd") {
                    item.dateAndTimeType = "pt";
                }
                else if (item.dateAndTimeType === "pt") {
                    item.dateAndTimeType = "pd";
                }
            }
        });
    };
    //更新校验类型下拉框数据
    const updateSelectColumnsRype = async (data) => {
        if (!data || !data.length) {
            return;
        }
        let newColumnsType = {
        // ...selectColumnsType,
        };
        let newBathType = {
        // ...selectBatchType
        };
        for (let i = 0; i < data.length; i++) {
            const item = data[i];
            const index = i;
            if (item.dynamicType === "MAIN" && item.dynamicType !== "null") {
                if (+item?.type === 4 && item.dateAndTimeType === "pd") {
                    newColumnsType[index] = CHECK_BATCH_CROSS_PD_TYPE;
                }
                if (+item?.type === 4 && item.dateAndTimeType === "pt") {
                    newColumnsType[index] = CHECK_BATCH_CROSS_PT_TYPE;
                }
                if (+item?.type !== 4 && item.dateAndTimeType === "pd") {
                    const pdOptions = await getPdYears();
                    newBathType[index] = pdOptions;
                }
                if (+item?.type !== 4 && item.dateAndTimeType === "pt") {
                    newBathType[index] = batchOptions;
                }
            }
        }
        if (Object.keys(newColumnsType).length > 0) {
            setSelectColumnsType({
                ...newColumnsType,
            });
        }
        if (Object.keys(newBathType).length > 0) {
            setSelectBatchType({
                ...newBathType,
            });
        }
    };
    const onDateAndTimeHandle = async (e, record, index) => {
        updateDateTimeDataList(index);
        console.log("onDateAndTimeHandle", dataList, record);
        setDataList([...dataList]);
        if (+record?.type === 4 && record.dateAndTimeType === "pd") {
            selectColumnsType[index] = CHECK_BATCH_CROSS_PD_TYPE;
            setSelectColumnsType({
                ...selectColumnsType,
            });
        }
        if (+record?.type === 4 && record.dateAndTimeType === "pt") {
            selectColumnsType[index] = CHECK_BATCH_CROSS_PT_TYPE;
            setSelectColumnsType({
                ...selectColumnsType,
            });
        }
        if (+record?.type !== 4 && record.dateAndTimeType === "pd") {
            const pdOptions = await getPdYears();
            setSelectBatchType({
                ...selectBatchType,
                [index]: pdOptions,
            });
        }
        if (+record?.type !== 4 && record.dateAndTimeType === "pt") {
            setSelectBatchType({
                ...selectBatchType,
                [index]: batchOptions,
            });
        }
    };
    const fetchParseVerifyFormat = async (formula) => {
        const headerColumn = params.gridRef.headerService.headerColumn;
        const gridData = params?.gridRef?.hot?.getData();
        const cpasTableType = params?.props?.type;
        const currentTName = params?.gridRef?.props.name;
        try {
            const currentYear = await getDataId();
            const response = await parseVerifyFormat({
                display_data: gridData,
                headerColumn,
                formula,
                cpasTableType,
                currentTName: currentTName,
                currentYear,
            });
            if (response && response?.data) {
                return response?.data;
            }
        }
        catch (e) {
            throw e;
        }
    };
    //判断是否是财务报表
    const isFinanceReport = params?.props?.type !== "zl" && params?.props?.type !== "ds" ? true : false;
    const debouncedApiCall = useCallback(debouncedApi, [dataList]);
    const dataColumns = [
        {
            title: "",
            width: 60,
            render: (_, record, index) => {
                return `${record.number}`;
            },
        },
        {
            title: "校验类型",
            dataIndex: "type",
            key: "type",
            width: 160,
            render: (_, record, index) => (_jsx(React.Fragment, { children: _jsx("div", { className: "check-type-box", children: _jsx(Select, { placeholder: "\u6821\u9A8C\u7C7B\u578B", options: isFinanceReport
                            ? checkType.slice(0, checkType.length - 1)
                            : checkType, className: "select_type", defaultValue: record.type, disabled: buttonDisabled, onChange: (val) => onChangeType(val, record, index) }, record.type) }) })),
        },
        {
            title: "",
            dataIndex: "dynamicCondition",
            key: "dynamicCondition",
            width: 46,
            render: (_, record, index) => (_jsx("div", { className: "batch-box", children: renderBatch(record, index) })),
        },
        {
            title: "",
            dataIndex: "dateAndTimeType",
            key: "dateAndTimeType",
            width: 46,
            render: (_, record, index) => (_jsx("div", { className: "datetime-box", children: record?.dynamicCondition ? (_jsx("div", { onClick: (e) => onDateAndTimeHandle(e, record, index), className: "datetime-button datetime-button-active", children: record?.dateAndTimeType === "pd" ? "段" : "点" })) : null })),
        },
        {
            title: "是否强制",
            dataIndex: "isForce",
            key: "isForce",
            width: 100,
            align: "center",
            render: (_, record) => (_jsx(Checkbox, { defaultChecked: record.isForce, onChange: () => (record.isForce = !record.isForce), disabled: buttonDisabled }, record.isForce)),
        },
        {
            title: "本表需校验内容",
            dataIndex: "beVerifiedFormula",
            key: "beVerifiedFormula",
            render: (_, record, index) => {
                let verifyResult;
                if (record.type === "4") {
                    let reg = new RegExp("V_CROSS", "g");
                    let verifyItem = record.beVerifiedFormula.replace(reg, "");
                    verifyResult = verifyItem.replace('("', "").replace('")', "");
                }
                return record.type === "4" ? (_jsx(Select, { placeholder: "\u8BF7\u9009\u62E9\u9700\u6821\u9A8C\u7C7B\u578B", options: selectColumnsType && selectColumnsType[index]
                        ? selectColumnsType[index]
                        : selectType, 
                    // defaultValue={verifyResult}
                    value: verifyResult, style: { width: "100%" }, disabled: buttonDisabled, onChange: (sel) => onSelectType(sel, record, index) })) : (_jsx(Tooltip, { title: () => {
                        return (_jsx("div", { dangerouslySetInnerHTML: {
                                __html: !record.dynamicCondition
                                    ? record.beVerifyFormat
                                    : record.beVerifiedFormula,
                            } }));
                    }, placement: "bottom", children: _jsx(TextArea, { rows: 3, placeholder: "请输入需校验内容", value: record.beVerifiedFormula, onChange: (e) => {
                            console.log(record, "record---");
                            const val = e.target.value;
                            record.beVerifiedFormula = val;
                            setDataList([...dataList]);
                            if (!record.dynamicCondition) {
                                debouncedApiCall(val, record, "beVerifyFormat", "beVerifiedFormula", params, dataList, setDataList);
                            }
                        }, className: classNames({ input_check_bg: index === isCheckFocus }), disabled: buttonDisabled, onFocus: () => {
                            setIsSourceOrCheck("check");
                            setIsDataFocus(null);
                            setIsCheckFocus(record.number);
                            setFocusList(record);
                        }, onClick: () => {
                            let tabKeys = [];
                            const newRes = tabItems.map((item) => {
                                if (item.key === "1") {
                                    tabKeys.push(item.key);
                                }
                                else {
                                }
                                return item;
                            });
                            setShowTabKeys(tabKeys);
                            console.log("onClick--check-focusList", focusList);
                            // setTabItems([...newRes]);
                            setIsSourceOrCheck("check");
                            setIsDataFocus(null);
                            setIsCheckFocus(record.number);
                            setFocusList(record);
                            setTabsShowValue("1");
                        } }, record.number) }));
            },
        },
        {
            title: "运算",
            dataIndex: "operation",
            key: "operation",
            width: 80,
            render: (_, record) => (_jsx(React.Fragment, { children: _jsx(Select, { placeholder: "\u8FD0\u7B97", options: operations, defaultValue: _, className: "select_data", disabled: buttonDisabled, onChange: (e) => {
                        record.operation = e;
                    } }, record.operation) })),
        },
        {
            title: "数据源",
            dataIndex: "verifyFormula",
            key: "verifyFormula",
            render: (_, record, index) => {
                let verifyResult;
                if (record.type === "4") {
                    let reg = new RegExp("V_CROSS", "g");
                    let verifyItem = record.verifyFormula.replace(reg, "");
                    verifyResult = verifyItem.replace('("', "").replace('")', "");
                }
                return record.type === "4" ? (_jsx(Select, { placeholder: "\u8BF7\u9009\u62E9\u6570\u636E\u6E90", options: selectColumnsType[index] ? selectColumnsType[index] : selectType, 
                    // defaultValue={verifyResult}
                    value: verifyResult, disabled: buttonDisabled, style: { width: "100%" }, onChange: (sel) => onSelectSource(sel, record, index) })) : (_jsx(Tooltip, { title: () => {
                        return (_jsx("div", { dangerouslySetInnerHTML: {
                                __html: !record.dynamicCondition
                                    ? record.verifyFormat
                                    : record.verifyFormula,
                            } }));
                    }, placement: "bottom", children: _jsx(TextArea, { rows: 3, placeholder: "\u8BF7\u8F93\u5165\u6570\u636E\u6E90", value: record.verifyFormula, ref: valueRef, className: index === isDataFocus ? "input_data_bg" : null, onChange: (e) => {
                            record.verifyFormula = e.target.value;
                            setDataList([...dataList]);
                            if (!record.dynamicCondition) {
                                debouncedApiCall(e.target.value, record, "verifyFormat", "verifyFormula", params, dataList, setDataList);
                            }
                        }, disabled: buttonDisabled, onFocus: () => {
                            setIsSourceOrCheck("source");
                            setIsCheckFocus(record.number);
                            setIsDataFocus(index);
                            setFocusList(record);
                        }, onClick: () => {
                            console.log("onClick---source ", record);
                            let tabKeys = [];
                            const currentType = +record.type;
                            setIsSourceOrCheck("source");
                            setIsCheckFocus(record.number);
                            setIsDataFocus(index);
                            setFocusList(record);
                            if (currentType === 1) {
                                setTabsShowValue("1");
                            }
                            //表间校验添加限制
                            if (currentType === 2) {
                                tabKeys = ["1", "3", "4", "5"];
                            }
                            else if (currentType === 3) {
                                //与报表校验添加限制
                                tabKeys = ["1", "2"];
                            }
                            else if (currentType === 1) {
                                //表内校验添加限制
                                tabKeys = ["1"];
                            }
                            setShowTabKeys(tabKeys);
                            if (!tabKeys.includes(tabsShowValue)) {
                                setTabsShowValue("1");
                            }
                        } }, record.number) }));
            },
        },
        {
            title: "",
            width: 100,
            dataIndex: "state",
            key: "state",
            render: (_, record, index) => (_jsx(React.Fragment, { children: _jsx("div", { className: "operation-state", children: _jsx("div", { className: "operation", children: renderOperation(_, record, index) }) }) })),
        },
    ];
    //找最大number数组
    const findMaxArray = (data) => {
        if (!data || !data.length) {
            return;
        }
        let numbers = [];
        for (let i = 0; i < data.length; i++) {
            const item = data[i];
            if (item.number) {
                const parentNum = item.number.toString().split("-")[0];
                if (item.dynamicType === "CHILD" && !numbers.includes(parentNum)) {
                    numbers.push(parentNum);
                }
            }
        }
        if (!numbers.length) {
            return;
        }
        return Math.max(...numbers);
    };
    const renderOperation = (_, record, index) => {
        //应需求及业务合理性要求：子公式只有最后一行展示加号
        if (record?.dynamicType === "CHILD") {
            const currentNumber = record.number;
            const parentNum = findMaxArray(dataList);
            //
            if (parentNum && !currentNumber.includes(parentNum)) {
                return;
            }
            if (currentNumber.toString().includes("-")) {
                const parentNumber = currentNumber.split("-")[0];
                const currentLists = dataList.filter((item) => item.number.toString().includes(`${parentNumber}-`));
                if (currentLists && currentLists.length && currentLists.length > 1) {
                    let numbers = [];
                    for (let i = 0; i < currentLists.length; i++) {
                        if (currentLists[i].number) {
                            const arr = currentLists[i].number.toString().split("-");
                            numbers.push(arr[1]);
                        }
                    }
                    const maxNum = Math.max(...numbers);
                    const maxData = currentLists.filter((item) => item.number.includes(`${parentNum}-${maxNum}`));
                    const maxNumber = maxData && maxData.length ? maxData[0].number : null;
                    //子公式除了最后一行展示加号操作，其他子公式不展示加减操作
                    if (maxNumber && maxNumber === record.number) {
                        return (_jsx(_Fragment, { children: _jsx(PlusOutlined, { onClick: () => addTableRowClick(_, record, index) }) }));
                    }
                    else {
                        return;
                    }
                }
            }
        }
        return (_jsxs(_Fragment, { children: [_jsx(PlusOutlined, { onClick: () => addTableRowClick(_, record, index) }), _jsx(MinusOutlined, { onClick: () => deleteTableRowClick(_, record, index) })] }));
    };
    const onChangeType = (type, record, index) => {
        fetchColumnData();
        if (type === "4") {
            setDisabled(true);
        }
        else {
            setDisabled(false);
        }
        record.dynamicCondition = null;
        setTabsShowValue("1");
        record.dateAndTimeType = "";
        record.type = type;
        setDataList([...dataList]);
    };
    const onGenerateDynamic = async () => {
        setLoading(true);
        console.log(dataList, "dataList-----");
        const listItem = await formatDataList("recalculate", dataList);
        params.gridRef.setTableContentChange(true, {
            type: "批量公式重算",
            params: {
                listItem,
            },
        });
        console.log("批量公式重算", listItem);
        setIsDynamicParent(true);
        params.gridRef.articulationVerifyService.parentDynamicMaps = [];
        const tid = params?.gridRef?.props?.notes?.tid;
        const type = params?.gridRef?.props.type;
        const genTid = type && type === "zl" ? `${tid}-zl` : tid;
        if (listItem.length > 0) {
            try {
                const result = await params.gridRef.articulationVerifyService.generateArtVerifyFormula(listItem, genTid);
                const { parentFormula, childFormula, otherChildFormula } = params.gridRef.articulationVerifyService.formatDynamicFormula(result, genTid);
                setDynamicParentFormularData(parentFormula);
                // if (otherChildFormula.length) {
                //   setDynamicOtherChildFormularData(otherChildFormula);
                // }
                if (childFormula && childFormula.length) {
                    message.success("公式已生成！");
                    delete selectColumnsType[0];
                    setSelectColumnsType({ ...selectColumnsType });
                    console.log(childFormula, "生成的子公式", selectColumnsType);
                    const createDataList = dataList.filter((item) => item.dynamicType !== "MAIN" &&
                        item.dynamicType !== "CHILD" &&
                        !item.dynamicCondition);
                    const allList = createDataList
                        ? [...childFormula, ...createDataList]
                        : childFormula;
                    const sortList = formatValidtorData(allList);
                    // const sortList = allList.sort(createComprisonFunction("number"));
                    // allList.map((item, index) => {
                    //   item.number = index + 1;
                    // });
                    console.log(sortList, "所有展示的公式");
                    // setDynamicChildFormularData(childFormula);
                    setDataList([...sortList]);
                }
                else {
                    message.warning("重算公式后的数据为空");
                }
            }
            catch (e) {
                message.warning("出错了，请检查设置重试～");
                console.log(e);
            }
        }
        setLoading(false);
    };
    const onClearGenerateDynamic = () => {
        if (!dynamicParentFormularData.length) {
            return message.warning("批量公式为空");
        }
        //本表勾稽校验母公式下DynamicMaps数据,还原操作后，删除非本表的数据需要
        let parentDynamicMaps = [];
        dynamicParentFormularData.map((item, index) => {
            if (item?.dynamicType === "MAIN" && item?.dynamicMaps) {
                parentDynamicMaps = parentDynamicMaps.concat(JSON.parse(item.dynamicMaps));
            }
            item.dynamicMaps = "";
            // item.number = index + 1;
        });
        console.log(parentDynamicMaps, "parentDynamicMaps 还原公式");
        params.gridRef.articulationVerifyService.parentDynamicMaps =
            parentDynamicMaps;
        if (dynamicParentFormularData) {
            const createDataList = dataList.filter((item) => item.dynamicType !== "CHILD" && item?.beVerifiedFormula);
            console.log(createDataList, "createDataList----", dataList);
            const allList = createDataList && createDataList.length
                ? [...dynamicParentFormularData, ...createDataList]
                : dynamicParentFormularData;
            // allList.map((item, index) => {
            //   item.number = index + 1;
            // });
            params.gridRef.articulationVerifyService.otherArtVerifyFormulaList = [];
            setIsDynamicParent(false);
            setDynamicOtherChildFormularData([]);
            const noRepeatList = [...formatValidtorData(allList)];
            //列表数据需要去重
            noRepeatList.map((item, index) => {
                item.number = index + 1;
            });
            setDataList([...noRepeatList]);
            updateSelectColumnsRype(noRepeatList);
        }
        return;
    };
    const tableSettingLeft = () => {
        return (_jsxs(React.Fragment, { children: [_jsx(CheckCircleOutlined, { style: { color: "green" } }), " \u6821\u9A8C\u89C4\u5219\u8BBE\u7F6E"] }));
    };
    const tableSettingRight = () => {
        const disabled = isMask ? true : false;
        let isShowRecalculate = true;
        if (dynamicParentFormularData && dynamicParentFormularData.length) {
            for (let i = 0; i < dynamicParentFormularData.length; i++) {
                if (dynamicParentFormularData[i]?.dynamicMaps) {
                    isShowRecalculate = false;
                }
            }
        }
        return (_jsxs("div", { className: "close-btn", children: [isShowRecalculate && (_jsx(Button, { onClick: () => onGenerateDynamic(), type: "default", disabled: disabled, children: "\u6279\u91CF\u516C\u5F0F\u91CD\u7B97" })), !isShowRecalculate && (_jsx(Button, { onClick: () => onClearGenerateDynamic(), type: "default", disabled: disabled, children: "\u6279\u91CF\u516C\u5F0F\u8FD8\u539F" })), _jsx(Button, { onClick: () => onClearTable(), type: "default", disabled: disabled, children: "\u6821\u9A8C\u516C\u5F0F\u6E05\u7A7A" }), _jsx(Button, { onClick: () => onFinishSave(), type: "default", disabled: disabled, children: "\u786E\u8BA4" })] }));
    };
    //格式化提交的数据
    const formatDataList = async (type, allDataList) => {
        const listItem = [];
        const allCrossPt = await getCrossPt();
        const allCrossPd = await getCrossPd();
        console.log(allCrossPt, "allCrossPt---", allCrossPd);
        if (type === "recalculate") {
            const isRecalculateFormula = allDataList.filter((item) => !item.dynamicCondition);
            if (isRecalculateFormula &&
                allDataList.length === isRecalculateFormula.length) {
                return message.warning("没有检测到批量公式，暂无法进行批量重算！");
            }
        }
        allDataList.map((item) => {
            if (!item.beVerifiedFormula || !item.verifyFormula) {
                setLoading(false);
                return handleOpen(false);
            }
            else {
                let dynamicList = [];
                const { dynamicCondition, dateAndTimeType } = item;
                if (+item.type === 4 && dynamicCondition) {
                    dynamicList = dateAndTimeType === "pt" ? allCrossPt : allCrossPd;
                }
                else if (dynamicCondition) {
                    if (Array.isArray(dynamicCondition)) {
                        dynamicList.push(...dynamicCondition);
                    }
                    else {
                        dynamicList = dynamicCondition;
                    }
                }
                let dynamicType = item?.dynamicCondition ? "MAIN" : "NULL";
                if (item?.dynamicType === "CHILD") {
                    dynamicType = item.dynamicType;
                }
                let obj = {
                    beVerifiedFormula: item.beVerifiedFormula,
                    verifyFormula: item.verifyFormula,
                    beVerifyFormat: item.beVerifyFormat,
                    verifyFormat: item.verifyFormat,
                    operation: item.operation,
                    number: item.number,
                    type: item.type,
                    isForce: item.isForce,
                    dynamicCondition: Array.isArray(dynamicList)
                        ? dynamicList.join()
                        : dynamicList,
                    dynamicType,
                    dateAndTimeType: item.dateAndTimeType,
                    dynamicMaps: item.dynamicMaps,
                    id: item.id,
                };
                return listItem.push(obj);
            }
        });
        return listItem;
    };
    const onFinishSave = async () => {
        setLoading(true);
        // const listItem = formatDataList("save");
        // const listItem = [];
        let allDataList = [];
        const newDataList = isDynamicParent
            ? dataList.filter((item) => item.dynamicType !== "MAIN")
            : dataList;
        console.log(newDataList, "newDataList-----dynamicParentFormularData", dynamicParentFormularData);
        if (isDynamicParent && dynamicParentFormularData.length) {
            allDataList.push(...dynamicParentFormularData);
        }
        if (newDataList) {
            allDataList.push(...newDataList);
        }
        if (dynamicOtherChildFormularData.length) {
            allDataList.push(...dynamicOtherChildFormularData);
        }
        // allDataList.map((item, index) => {
        //   item.number = index + 1;
        // });
        console.log(allDataList, "allDataList 所有数据");
        const isCROSSData = allDataList.filter((item) => +item.type === 4);
        const cpastableData = params?.gridRef?.hot?.getData();
        //交叉校验限制要求：表内数据需要要大于三行以上
        if (isCROSSData && isCROSSData.length && cpastableData.length < 4) {
            setLoading(false);
            return message.warning("表内数据需大于等于三行以上，请重新配置数据！");
        }
        const listItem = await formatDataList("save", allDataList);
        setLoading(false);
        params.gridRef.setTableContentChange(true, {
            type: "勾稽校验保存",
            params: {
                listItem,
            },
        });
        console.log("设置校验公式", listItem);
        if (listItem.length > 0) {
            try {
                const result = await params.gridRef.articulationVerifyService.parseArtVerifyFormula(listItem);
                params.gridRef.articulationVerifyService.clearArtVerifyMark();
                const formularList = transformCrossData(result);
                formularList.map((item) => {
                    params.gridRef.articulationVerifyService.markBeVerifiedItem(item, false, true);
                });
                console.log("校验结果", result);
                if (result.length > 0) {
                    handleOpen(false);
                    setLoading(false);
                    setDataList([...allDataList]);
                    const setDSVerifyResult = params?.props?.gridRef?.props?.dsTableRef?.setDSVerifyResult;
                    if (setDSVerifyResult) {
                        setDSVerifyResult(params?.gridRef?.articulationVerifyService?.artParseResultList); //更新整理模式校验详情数据
                    }
                    return message.success("校验规则设置成功！");
                }
                else {
                    setLoading(false);
                }
            }
            catch (error) {
                console.log(error);
                setLoading(false);
                return message.warning("校验公式设置错误，请重新设置！");
            }
        }
        else {
            setLoading(false);
        }
    };
    const onClearTable = async () => {
        setConfirmBtn(true);
        const removeVerify = await removeVerifyData({
            tid: params.gridRef.props.notes.tid,
        });
        setIsDynamicParent(false);
        params.gridRef.articulationVerifyService.artVerifyFormulaList = [];
        params.gridRef.articulationVerifyService.artParseResultList = [];
        params.gridRef.articulationVerifyService.otherArtVerifyFormulaList = [];
        params.gridRef.articulationVerifyService.clearArtVerifyMark();
        // 校验公式
        // params.gridRef.props.innerRef.current.articulationVerifyService.artVerifyFormulaList =
        //   [];
        // params.gridRef.props.innerRef.current.articulationVerifyService.artParseResultList =
        //   [];
        // params.gridRef.props.innerRef.current.articulationVerifyService.clearArtVerifyMark();
        setIsCheckFocus(null);
        setIsDataFocus(null);
        setDynamicParentFormularData([]);
        // setDynamicChildFormularData([]);
        setDynamicOtherChildFormularData([]);
        setDataList([]);
        const tab = {
            number: 1,
            type: "1",
            isForce: true,
            beVerifiedFormula: "",
            operation: "==",
            verifyFormula: "",
            dynamicCondition: null,
            dateAndTimeType: "",
            dynamicMaps: "",
            beVerifyFormat: "",
            verifyFormat: "",
        };
        setDataList([tab]);
    };
    const addTableRowClick = (_, record, index) => {
        let defaultData = {
            ...record,
            verifyFormula: "",
            beVerifiedFormula: "",
            dynamicCondition: "",
            dateAndTimeType: "",
            dynamicMaps: "",
            dynamicType: "",
            id: "",
            beVerifyFormat: "",
            verifyFormat: "",
        };
        if (buttonDisabled) {
            return;
        }
        if (dataList && dataList.length === 1) {
            dataList.push({
                ...defaultData,
                number: +dataList[0].number + 1,
            });
            setDataList([...dataList]);
            return;
        }
        let beforeData = dataList.slice(0, index + 1);
        const number = beforeData && beforeData.length
            ? beforeData[beforeData.length - 1].number
            : 1;
        const newNumber = number.toString().includes("-")
            ? `${+number.split("-")[0] + 1}`
            : +number + 1;
        const afterData = dataList.slice(index + 1, dataList.length);
        beforeData.push({
            ...defaultData,
            number: newNumber,
        });
        let refreshParentNumber = []; //需要刷新的母公式
        for (let i = 0; i < afterData.length; i++) {
            const item = afterData[i];
            const number = item.number.toString();
            if (number && number.includes("-")) {
                const parentNumber = +number.split("-")[0];
                const childNumber = +number.split("-")[1];
                refreshParentNumber.push(parentNumber);
                afterData[i].number = `${parentNumber + 1}-${childNumber}`;
            }
            else {
                afterData[i].number = `${+number + 1}`;
            }
        }
        if (refreshParentNumber.length &&
            dynamicParentFormularData &&
            dynamicParentFormularData.length) {
            for (let i = 0; i < refreshParentNumber.length; i++) {
                const parentNumber = refreshParentNumber[i];
                for (let j = 0; j < dynamicParentFormularData.length; j++) {
                    if (parentNumber === dynamicParentFormularData[j]?.number) {
                        dynamicParentFormularData[j].number = `${+parentNumber + 1}`;
                    }
                }
            }
            setDynamicParentFormularData(dynamicParentFormularData);
        }
        // dataList.splice(index + 1, 0, {
        //   ...defaultData,
        // });
        // dataList.map((item, index) => {
        //   item.number = index + 1;
        // });
        setDataList(beforeData.concat(afterData));
    };
    /**
     * 根据index删除对应的array并排序
     */
    const indexDelSort = (index, array) => {
        if (!array || !array.length) {
            return;
        }
        if (array.length < 3) {
            array.splice(index, 1);
            array[0].number = 1;
            return array;
        }
        let beforeData = array.slice(0, index);
        const afterData = array.slice(index + 1, array.length);
        console.log(beforeData, "beforeData----afterData", afterData, index);
        let refreshParentNumber = []; //需要刷新的母公式
        for (let i = 0; i < afterData.length; i++) {
            const item = afterData[i];
            const number = item.number.toString();
            if (number && number.includes("-")) {
                const parentNumber = +number.split("-")[0];
                const childNumber = +number.split("-")[1];
                refreshParentNumber.push(parentNumber);
                afterData[i].number = `${parentNumber - 1}-${childNumber}`;
            }
            else {
                afterData[i].number = `${+number - 1}`;
            }
        }
        if (refreshParentNumber.length &&
            dynamicParentFormularData &&
            dynamicParentFormularData.length) {
            for (let i = 0; i < refreshParentNumber.length; i++) {
                const parentNumber = refreshParentNumber[i];
                for (let j = 0; j < dynamicParentFormularData.length; j++) {
                    if (parentNumber === dynamicParentFormularData[j]?.number) {
                        dynamicParentFormularData[j].number = `${+parentNumber - 1}`;
                    }
                }
            }
            setDynamicParentFormularData(dynamicParentFormularData);
        }
        return beforeData.concat(afterData);
    };
    const deleteTableRowClick = (_, record, index) => {
        let resultList = params.gridRef.articulationVerifyService.artParseResultList;
        // if (Object.keys(batchValue).length) {
        //   let newBatchValue = {};
        //   for (let key in batchValue) {
        //     if (key < index) {
        //       newBatchValue[key] = batchValue[key];
        //     }
        //     // if(key === index) {
        //     //   delete newBatchValue[key]
        //     // }
        //     if (key > index) {
        //       const i = parseInt(key) - 1;
        //       newBatchValue[i] = batchValue[key];
        //     }
        //   }
        //   console.log(newBatchValue, "newBatchValue----");
        //   setBatchValue(newBatchValue);
        // }
        if (buttonDisabled) {
            return;
        }
        if (resultList.length > 0) {
            resultList.map((item, index) => {
                if (record.number === item.number) {
                    resultList.splice(index, 1);
                }
            });
            if (dataList.length > 1) {
                const newDataList = indexDelSort(index, dataList);
                // dataList.map((item, index) => {
                //   item.number = index + 1;
                // });
                setDataList([...newDataList]);
            }
            else {
                alert("抱歉当前行无法删除");
            }
        }
        else {
            if (dataList.length > 1) {
                const newDataList = indexDelSort(index, dataList);
                // dataList.map((item, index) => {
                //   item.number = index + 1;
                // });
                setDataList([...newDataList]);
            }
            else {
                alert("抱歉当前行无法删除");
            }
        }
    };
    const onChangeTabs = async (key) => {
        setTabsShowValue(key);
        tableBook.current.valueFun();
    };
    // 过滤默认 第一条
    const fetchColumnData = (columnIndex) => {
        const data = params.gridRef.headerService.headerColumn;
        const gridData = params?.gridRef?.hot?.getData();
        for (let i = 0; i < data.length; i++) {
            const maps = params.gridRef.gridService.getMapsByCoords(gridData, {
                row: 0,
                col: i,
            });
            data[i]["columnMap"] = maps.cmap;
        }
        let newData = data.filter((item, index) => {
            return (index !== 0 &&
                index !== data.length - 1 &&
                item?.config?.type !== "text");
        });
        const ab = newData.map((item) => {
            let obj = {
                value: item?.columnMap,
            };
            return obj;
        });
        console.log(ab, "ab------");
        if (columnIndex || columnIndex === 0) {
            selectColumnsType[columnIndex] = ab;
            setSelectColumnsType({
                ...selectColumnsType,
            });
        }
        else {
            setSelectType(ab);
        }
    };
    const onSelectType = (sel, record, index) => {
        console.log("onSelectType");
        record.beVerifiedFormula = `V_CROSS("${sel}")`;
        dataList[index].beVerifiedFormula = `V_CROSS("${sel}")`;
        setDataList([...dataList]);
    };
    const onSelectSource = (sel, record, index) => {
        record.verifyFormula = `V_CROSS("${sel}")`;
        dataList[index].verifyFormula = `V_CROSS("${sel}")`;
        setDataList([...dataList]);
    };
    console.log(params.gridRef, "gridDatas---isSourceOrCheck", isSourceOrCheck);
    // const tabsItems = [
    //   {
    //     key: "1",
    //     label: `表内`,
    //     forceRender: true,
    //     children: (
    //       <div>
    //         <TableBase
    //           ref={tableBook}
    //           dataList={dataList}
    //           setDataList={setDataList}
    //           sourceOrCheck={isSourceOrCheck}
    //           data={focusList}
    //           keys={tabsShowValue}
    //           gridDatas={params.gridRef.getCpasTableGrid()}
    //           parentType={params?.gridRef?.props.type}
    //           parentName={params?.gridRef?.props.name}
    //           parentParamsRef={params}
    //         />
    //       </div>
    //     ),
    //   },
    //   mergeType === MergeType.TEMPLATE
    //     ? null
    //     : {
    //       key: "2",
    //       label: `报表基础数据`,
    //       forceRender: true,
    //       children: (
    //         <div>
    //           <TableReport
    //             ref={tableBook}
    //             dataList={dataList}
    //             setDataList={setDataList}
    //             testColumns={columnsData}
    //             testData={testData}
    //             data={focusList}
    //             keys={tabsShowValue}
    //             sourceOrCheck={isSourceOrCheck}
    //             parentParamsRef={params}
    //           />
    //         </div>
    //       ),
    //       disabled: isDisabled,
    //     },
    //   {
    //     key: "3",
    //     label: `附注数据`,
    //     forceRender: true,
    //     children: (
    //       <div>
    //         <TableBook
    //           ref={tableBook}
    //           keys={tabsShowValue}
    //           dataList={dataList}
    //           focusItem={focusList}
    //           setDataList={setDataList}
    //           sourceOrCheck={isSourceOrCheck}
    //           dataIndex={isCheckFocus}
    //           gridDatas={params.gridRef}
    //           parentParamsRef={params}
    //         />
    //       </div>
    //     ),
    //     disabled: isDisabled,
    //   },
    //   {
    //     key: "4",
    //     label: `报表`,
    //     forceRender: true,
    //     children: (
    //       <div>
    //         <TableFS
    //           ref={tableBook}
    //           keys={tabsShowValue}
    //           dataList={dataList}
    //           focusItem={focusList}
    //           setDataList={setDataList}
    //           sourceOrCheck={isSourceOrCheck}
    //           dataIndex={isCheckFocus}
    //           gridDatas={params.gridRef}
    //           parentParamsRef={params}
    //         />
    //       </div>
    //     ),
    //     disabled: isDisabled,
    //   },
    //   {
    //     key: "5",
    //     label: `试算平衡表`,
    //     forceRender: true,
    //     children: (
    //       <div>
    //         <TrialTableFS
    //           ref={tableBook}
    //           keys={tabsShowValue}
    //           dataList={dataList}
    //           focusItem={focusList}
    //           setDataList={setDataList}
    //           sourceOrCheck={isSourceOrCheck}
    //           dataIndex={isCheckFocus}
    //           gridDatas={params.gridRef}
    //           parentParamsRef={params}
    //         />
    //       </div>
    //     ),
    //     disabled: isDisabled,
    //   },
    // ];
    const fetchCheckBaseData = async () => {
        const datId = await getDataId();
        const params = {
            name: "base.reportItems",
            data_id: datId,
            fields: [],
            where: "",
            order: "",
        };
        const data = await getDisclosureData(params);
        if (data.ok) {
            if (data.data.length > 0) {
                let numArray = [];
                let strArray = [];
                const columnsData = data.data[0];
                Object.keys(columnsData).map((p) => {
                    console.log(p, "p---columnsData---", columnsData[p]);
                    if (typeof columnsData[p] === "number") {
                        numArray.push({
                            dataField: p,
                            caption: p,
                            alignment: "right",
                            width: 120,
                        });
                    }
                    else if (columnsData[p].length <= 2 &&
                        typeof columnsData[p] === "string") {
                        numArray.push({
                            dataField: p,
                            caption: p,
                            alignment: "center",
                            width: 120,
                        });
                    }
                    else {
                        strArray.push({
                            dataField: p,
                            caption: p,
                            alignment: "left",
                            width: 120,
                        });
                    }
                });
                let newlist = [...strArray].concat([...numArray]);
                for (let i = 0; i < newlist.length; i++) {
                    if (i === 0) {
                        newlist[i].fixed = true;
                        newlist[i].width = 180;
                    }
                    const caption = newlist[i]?.caption;
                    //仅在报告系统下生效。@需求要求
                    if (mergeType === MergeType.UNKNOW &&
                        caption &&
                        (caption === "审定数" ||
                            caption === "期末审定数" ||
                            caption === "本期审定发生额")) {
                        newlist[i].cssClass = "repeort-cell-highlighted";
                    }
                }
                const db = newlist.filter((c, index) => c.dataField !== "是否关键账户" && c.dataField !== "合计项级别");
                localStorage.setItem("tableColums", JSON.stringify(db));
                return setColumnsData(db);
            }
        }
        else {
            return message.error("数据加载失败");
        }
    };
    return (_jsx(React.Fragment, { children: _jsx(Modal, { open: isOpen, width: "90%", onCancel: () => handleOpen(false), maskClosable: false, footer: null, className: "setting", children: _jsx(Spin, { tip: "Loading", size: "small", spinning: loading, delay: 500, children: _jsxs(Card, { title: tableSettingLeft(), extra: tableSettingRight(), bordered: false, className: "setting-card", children: [_jsx("div", { style: { height: "270px" }, className: "validator-body", children: _jsx(Table, { className: "table-up", columns: dataColumns, dataSource: dataList, pagination: false, rowKey: (record) => record.number, scroll: { y: 200 } }) }), _jsx(Tabs, { activeKey: tabsShowValue, items: tabItems, onChange: onChangeTabs })] }) }) }) }));
};
export default CheckModalComponent;
